package com.hjx.servlet;

import com.hjx.service.orderService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

public class delOrderServlet extends HttpServlet {
    private orderService order=null;
    private int count=0;
    private HttpSession session=null;
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        order=new orderService();
        session=req.getSession();
        String coding=req.getParameter("coding");
        System.out.println("要删除的coding="+coding);
        Object[] args=new Object[]{
                coding
        };
       try {
           if (args[0]==null || args[0]==""){
               System.out.println("删除coding为空");
               resp.sendRedirect("/super/Page/index.jsp");
           }else {
               count=order.delOrder(args);
               resp.sendRedirect("/super/Page/index.jsp");
           }
           if (count>=1){
               System.out.println("删除成功！");
               session.setAttribute("status","success");
           }else {
               session.setAttribute("status","error");
           }
       } catch (Exception exception) {
           exception.printStackTrace();
       }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    }
}
